*Appendix Replication file for "Global Finance, Political Business Cycles, and the Politics of Foreign Reserves"
*Ben Cormier and Patrick Shea
*Analysis run in Stata 15
*Data sources cited in text

*Packages:
*ssc install estout
*ssc install ebalance
*ssc install interflex


use "data1_final.dta", clear


***************************************************************************************************************************************************************************
*Data prep
tsset country_num year
*Set color scheme for plots
set scheme s1mono
grstyle init
grstyle set plain, nogrid 

*Subset to developing
keep if oecd_1yes == 0
*Subset to VDem democracy level
keep if v2x_polyarchy > .42


***************************************************************************************************************************************************************************
*Section A: Country Years (from full model)
regress deltaReserves_Imports i.ElectionPeriod##c.US10YrYields_AnnAvg ElectionYear l.deltaReserves_Imports l.GDPpcap l.GDPgrowth l.ny_gdp_totl_rt_zs l.CurrAcctBal_PerGDP l.ExtDebtStocks_PerGNI l.DebtService_PerGDP l.Inflation_annGDPdeflator l.PegBandManaged_NoUnion l.lvaw_garriga l.Taxes_PerGDP l.BestCRtg l.cyrs l.dyrs l.v2x_polyarchy l.Left i.country_num c.year##c.GlobalReserveLevels, robust
gen in_model = e(sample)
keep if in_model==1
*Then export into an excel and manually identify country-years in sample. For eg, use "export excel using "/Users/ben/Dropbox/Reserves/Appendix/CtyYears.xlsx"


***************************************************************************************************************************************************************************
*Section B: Descriptive Stats for complete cases in Model 4
regress deltaReserves_Imports i.ElectionPeriod##c.US10YrYields_AnnAvg ElectionYear l.deltaReserves_Imports l.GDPpcap l.GDPgrowth l.ny_gdp_totl_rt_zs l.CurrAcctBal_PerGDP l.ExtDebtStocks_PerGNI l.DebtService_PerGDP l.Inflation_annGDPdeflator l.PegBandManaged_NoUnion l.lvaw_garriga l.Taxes_PerGDP l.BestCRtg l.cyrs l.dyrs l.v2x_polyarchy l.Left i.country_num c.year##c.GlobalReserveLevels, robust
sum  deltaReserves_Imports ElectionPeriod US10YrYields_AnnAvg  ElectionYear deltaReserves_Imports GDPpcap GDPgrowth ny_gdp_totl_rt_zs CurrAcctBal_PerGDP ExtDebtStocks_PerGNI DebtService_PerGDP Inflation_annGDPdeflator PegBandManaged_NoUnion lvaw_garriga Taxes_PerGDP BestCRtg cyrs dyrs v2x_polyarchy Left if e(sample)



***************************************************************************************************************************************************************************
*Section C: Alt Democracy Datasets and Thresholds


*Re-set to expand from .42 polyarchy scope
use "data1_final.dta", clear
*Data prep
tsset country_num year

*Subset to developing
keep if oecd_1yes == 0

* Generate pre-election share
replace  monthDPI= . if ElectionPeriod==0 

gen preelec_share = 0 if year <=2020
replace preelec_share = monthDPI/12 if monthDPI != . 
by iso, sort: replace preelec_share = (12-monthDPI[_n+1])/12 if monthDPI[_n+1] != .

tsset country_num year


* Generate post-election share (monthly) 
gen postelec_share = 0 if year <=2020
replace postelec_share = (12-monthDPI)/12 if monthDPI != .

* Generate post-election share (annual) 

gen post_Election =0 if year <=2020
replace post_Election =1 if year <=2020 & ElectionLastYear==1



lab var US10YrYields_AnnAvg "USrates"
lab var CurrAcctBal_PerGDP  "CurrAcct"
lab var lvaw_garriga "CBI"
lab var Taxes_PerGDP "TaxRevenue"
lab var ny_gdp_totl_rt_zs "NatRents"
lab var cyrs "CCrisisYrs"
lab var dyrs "DCrisisYrs"
lab var BestCRtg "CreditRating"
lab var v2x_polyarchy "Democracy"
lab var DebtService_PerGDP "DebtService"
lab var Inflation_annGDPdeflator "Inflation"
lab var ExtDebtStocks_PerGNI "ExtDebt"
lab var PegBandManaged_NoUnion "PegBand"
lab var deltaReserves_Imports "Reserves"
lab var year "Year"
lab var post_Election "Post-Election"



*Lower Vdem
gen sample2 = 1 if v2x_polyarchy > .33 
*Polit
*Boix et al binary
gen sample3 = 1 if democracy==1 
*Vdem regimes with elections (excluding autocracies)
gen sample4 = 1 if v2x_regime==2 | v2x_regime==3


regress deltaReserves_Imports c.ElectionPeriod##c.US10YrYields_AnnAvg ElectionYear  l.(deltaReserves_Imports GDPpcap GDPgrowth ny_gdp_totl_rt_zs CurrAcctBal_PerGDP ExtDebtStocks_PerGNI DebtService_PerGDP Inflation_annGDPdeflator PegBandManaged_NoUnion lvaw_garriga Taxes_PerGDP BestCRtg cyrs dyrs v2x_polyarchy Left) i.country_num c.year##c.GlobalReserveLevels if sample2==1, robust
estimates store m2

regress deltaReserves_Imports c.ElectionPeriod##c.US10YrYields_AnnAvg ElectionYear  l.(deltaReserves_Imports GDPpcap GDPgrowth ny_gdp_totl_rt_zs CurrAcctBal_PerGDP ExtDebtStocks_PerGNI DebtService_PerGDP Inflation_annGDPdeflator PegBandManaged_NoUnion lvaw_garriga Taxes_PerGDP BestCRtg cyrs dyrs v2x_polyarchy Left) i.country_num c.year##c.GlobalReserveLevels if sample3==1, robust
estimates store m3

regress deltaReserves_Imports c.ElectionPeriod##c.US10YrYields_AnnAvg ElectionYear  l.(deltaReserves_Imports GDPpcap GDPgrowth ny_gdp_totl_rt_zs CurrAcctBal_PerGDP ExtDebtStocks_PerGNI DebtService_PerGDP Inflation_annGDPdeflator PegBandManaged_NoUnion lvaw_garriga Taxes_PerGDP BestCRtg cyrs dyrs v2x_polyarchy Left) i.country_num c.year##c.GlobalReserveLevels if sample4==1, robust
estimates store m4


lab var post_Election "Post-Election"

estout m2 m3 m4, cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) starlevels(* 0.1 ** 0.05 ) ///
stats(r2 N , fmt(%9.2f %9.0f) labels("R2" ))  style(tex) ///
legend label collabels(none) ///
varlabels(_cons Constant  "c.ElectionPeriod#c.US10YrYields_AnnAvg" "Election*USrates" "c.year#c.GlobalReserveLevels000" "Year*GlobalReserves") ///
keep(ElectionPeriod US10YrYields_AnnAvg c.ElectionPeriod#c.US10YrYields_AnnAvg ElectionYear)  ///
mlabels () ///
title("") 




***************************************************************************************************************************************************************************
*Section D: Matched sample with Entropy 


*Re-set to main sample
use "data1_final.dta", clear
*Data prep
tsset country_num year

*Subset to developing
keep if oecd_1yes == 0
*Subset to VDem democracy level
keep if v2x_polyarchy > .42

* Generate pre-election share
replace  monthDPI= . if ElectionPeriod==0 

gen preelec_share = 0 if year <=2020
replace preelec_share = monthDPI/12 if monthDPI != . 
by iso, sort: replace preelec_share = (12-monthDPI[_n+1])/12 if monthDPI[_n+1] != .

tsset country_num year


* Generate post-election share (monthly) 
gen postelec_share = 0 if year <=2020
replace postelec_share = (12-monthDPI)/12 if monthDPI != .

* Generate post-election share (annual) 

gen post_Election =0 if year <=2020
replace post_Election =1 if year <=2020 & ElectionLastYear==1



gen investgrade = 0 
replace investgrade = 1 if BestCRtg>=15



*Entropy balance
ebalance investgrade GDPpcap GDPgrowth ny_gdp_totl_rt_zs ///
 DebtService_PerGDP lvaw_garriga Taxes_PerGDP v2x_polyarchy Inflation_annGDPdeflator  Left PegBandManaged_NoUnion  ///
, ///
tar(3 3 1 1 1 1 1 1 1 1 ) gen(ebw1) k(baltab) replace

sort country_num year
by country_num: egen avg_w = mean(ebw1)

svyset [pw=avg_w]


regress deltaReserves_Imports ElectionPeriod ElectionYear  US10YrYields_AnnAvg l.deltaReserves_Imports l.GDPpcap l.GDPgrowth l.ny_gdp_totl_rt_zs l.CurrAcctBal_PerGDP l.ExtDebtStocks_PerGNI l.DebtService_PerGDP l.Inflation_annGDPdeflator l.PegBandManaged_NoUnion l.lvaw_garriga l.Taxes_PerGDP l.BestCRtg l.cyrs l.dyrs l.v2x_polyarchy l.Left i.country_num c.year##c.GlobalReserveLevels [pweight=avg_w], robust
estimates store e1

regress deltaReserves_Imports c.ElectionPeriod##c.US10YrYields_AnnAvg  i.country_num [pweight=avg_w], robust
estimates store e2

regress deltaReserves_Imports c.ElectionPeriod##c.US10YrYields_AnnAvg ElectionYear l.deltaReserves_Imports i.country_num c.year##c.GlobalReserveLevels [pweight=avg_w], robust
estimates store e3

regress deltaReserves_Imports c.ElectionPeriod##c.US10YrYields_AnnAvg ElectionYear l.deltaReserves_Imports l.GDPpcap l.GDPgrowth l.ny_gdp_totl_rt_zs l.CurrAcctBal_PerGDP l.ExtDebtStocks_PerGNI l.DebtService_PerGDP l.Inflation_annGDPdeflator l.PegBandManaged_NoUnion l.lvaw_garriga l.Taxes_PerGDP l.BestCRtg l.cyrs l.dyrs l.v2x_polyarchy l.Left i.country_num c.year##c.GlobalReserveLevels [pweight=avg_w], robust
estimates store e4


estout e4, cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) starlevels(* 0.1 ** 0.05 ) ///
stats(r2 N , fmt(%9.2f %9.0f) labels("R2" ))  style(tex) ///
legend label collabels(none)  ///
varlabels(_cons Constant  "c.ElectionPeriod#c.US10YrYields_AnnAvg" "Election*USrates" "c.year#c.GlobalReserveLevels000" "Year*GlobalReserves") order(ElectionPeriod US10YrYields_AnnAvg ElectionYear  c.ElectionPeriod#c.US10YrYields_AnnAvg) ///
 drop(*country_num c.year#c.GlobalReserveLevels GlobalReserveLevels year) ///
mlabels () ///
title("") 


***************************************************************************************************************************************************************************
*Section E: Hetereogenous Effects

tab country_num , gen(cn_)

regress deltaReserves_Imports c.ElectionPeriod##c.US10YrYields_AnnAvg ElectionYear l.deltaReserves_Imports l.GDPpcap l.GDPgrowth l.ny_gdp_totl_rt_zs l.CurrAcctBal_PerGDP l.ExtDebtStocks_PerGNI l.DebtService_PerGDP l.Inflation_annGDPdeflator l.PegBandManaged_NoUnion l.Taxes_PerGDP l.BestCRtg l.cyrs l.dyrs l.v2x_polyarchy l.Left cn_* c.year##c.GlobalReserveLevels if  lvaw_garriga>=.64825, robust
estimates store c1a

regress deltaReserves_Imports c.ElectionPeriod##c.US10YrYields_AnnAvg ElectionYear l.deltaReserves_Imports l.GDPpcap l.GDPgrowth l.ny_gdp_totl_rt_zs l.CurrAcctBal_PerGDP l.ExtDebtStocks_PerGNI l.DebtService_PerGDP l.Inflation_annGDPdeflator l.PegBandManaged_NoUnion l.Taxes_PerGDP l.BestCRtg l.cyrs l.dyrs l.v2x_polyarchy l.Left cn_* c.year##c.GlobalReserveLevels if  lvaw_garriga<.64825, robust
estimates store c2a


regress deltaReserves_Imports c.ElectionPeriod##c.US10YrYields_AnnAvg ElectionYear l.deltaReserves_Imports l.GDPpcap l.GDPgrowth l.ny_gdp_totl_rt_zs l.CurrAcctBal_PerGDP l.ExtDebtStocks_PerGNI l.DebtService_PerGDP l.Inflation_annGDPdeflator l.PegBandManaged_NoUnion l.Taxes_PerGDP l.BestCRtg l.cyrs l.dyrs l.v2x_polyarchy l.Left cn_* c.year##c.GlobalReserveLevels if  lvaw_garriga>=.64825
estimates store c1

regress deltaReserves_Imports c.ElectionPeriod##c.US10YrYields_AnnAvg ElectionYear l.deltaReserves_Imports l.GDPpcap l.GDPgrowth l.ny_gdp_totl_rt_zs l.CurrAcctBal_PerGDP l.ExtDebtStocks_PerGNI l.DebtService_PerGDP l.Inflation_annGDPdeflator l.PegBandManaged_NoUnion l.Taxes_PerGDP l.BestCRtg l.cyrs l.dyrs l.v2x_polyarchy l.Left cn_* c.year##c.GlobalReserveLevels if  lvaw_garriga<.64825
estimates store c2


suest c1 c2

test [c1_mean]c.ElectionPeriod#c.US10YrYields_AnnAvg = [c2_mean]c.ElectionPeriod#c.US10YrYields_AnnAvg


regress deltaReserves_Imports c.ElectionPeriod##c.US10YrYields_AnnAvg ElectionYear l.deltaReserves_Imports l.GDPpcap l.GDPgrowth l.ny_gdp_totl_rt_zs l.CurrAcctBal_PerGDP l.ExtDebtStocks_PerGNI l.DebtService_PerGDP l.Inflation_annGDPdeflator  l.lvaw_garriga l.Taxes_PerGDP l.BestCRtg l.cyrs l.dyrs l.v2x_polyarchy l.Left cn_* c.year##c.GlobalReserveLevels if  PegBandManaged_NoUnion==1, robust
estimates store c3a

regress deltaReserves_Imports c.ElectionPeriod##c.US10YrYields_AnnAvg ElectionYear l.deltaReserves_Imports l.GDPpcap l.GDPgrowth l.ny_gdp_totl_rt_zs l.CurrAcctBal_PerGDP l.ExtDebtStocks_PerGNI l.DebtService_PerGDP l.Inflation_annGDPdeflator l.lvaw_garriga l.Taxes_PerGDP l.BestCRtg l.cyrs l.dyrs l.v2x_polyarchy l.Left cn_* c.year##c.GlobalReserveLevels if  PegBandManaged_NoUnion==0, robust
estimates store c4a


regress deltaReserves_Imports c.ElectionPeriod##c.US10YrYields_AnnAvg ElectionYear l.deltaReserves_Imports l.GDPpcap l.GDPgrowth l.ny_gdp_totl_rt_zs l.CurrAcctBal_PerGDP l.ExtDebtStocks_PerGNI l.DebtService_PerGDP l.Inflation_annGDPdeflator l.PegBandManaged_NoUnion l.lvaw_garriga l.Taxes_PerGDP l.BestCRtg l.cyrs l.dyrs l.v2x_polyarchy l.Left cn_* c.year##c.GlobalReserveLevels if  PegBandManaged_NoUnion==1
estimates store c3

regress deltaReserves_Imports c.ElectionPeriod##c.US10YrYields_AnnAvg ElectionYear l.deltaReserves_Imports l.GDPpcap l.GDPgrowth l.ny_gdp_totl_rt_zs l.CurrAcctBal_PerGDP l.ExtDebtStocks_PerGNI l.DebtService_PerGDP l.Inflation_annGDPdeflator l.PegBandManaged_NoUnion l.lvaw_garriga l.Taxes_PerGDP l.BestCRtg l.cyrs l.dyrs l.v2x_polyarchy l.Left cn_* c.year##c.GlobalReserveLevels if  PegBandManaged_NoUnion==0
estimates store c4


suest c3 c4

test [c3_mean]c.ElectionPeriod#c.US10YrYields_AnnAvg = [c4_mean]c.ElectionPeriod#c.US10YrYields_AnnAvg

estout c1a c2a c3a c4a, cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) starlevels(* 0.1 ** 0.05 ) ///
stats(r2 N , fmt(%9.2f %9.0f) labels("R2" ))  style(tex) ///
legend label collabels(none) ///
varlabels(_cons Constant  "c.ElectionPeriod#c.US10YrYields_AnnAvg" "Election*USrates" "c.year#c.GlobalReserveLevels000" "Year*GlobalReserves") ///
keep(ElectionPeriod US10YrYields_AnnAvg c.ElectionPeriod#c.US10YrYields_AnnAvg ElectionYear)  ///
mlabels () ///
title("") 

***************************************************************************************************************************************************************************
*Section F: Multicollinearity

regress deltaReserves_Imports c.ElectionPeriod c.US10YrYields_AnnAvg ElectionYear l.deltaReserves_Imports l.GDPpcap l.GDPgrowth l.ny_gdp_totl_rt_zs l.CurrAcctBal_PerGDP l.ExtDebtStocks_PerGNI l.DebtService_PerGDP l.Inflation_annGDPdeflator l.PegBandManaged_NoUnion l.lvaw_garriga l.Taxes_PerGDP l.BestCRtg l.cyrs l.dyrs l.v2x_polyarchy l.Left i.country_num c.year##c.GlobalReserveLevels, robust
estimates store c1

vif


regress deltaReserves_Imports c.ElectionPeriod##c.US10YrYields_AnnAvg ElectionYear l.deltaReserves_Imports l.GDPgrowth l.CurrAcctBal_PerGDP l.ExtDebtStocks_PerGNI l.DebtService_PerGDP l.Inflation_annGDPdeflator l.PegBandManaged_NoUnion l.Left i.year i.country_num, robust
estimates store c2

vif

gen postcrisis =0
replace postcrisis = 1 if year >=2012

gen precrisis =0
replace precrisis = 1 if year <2007


regress deltaReserves_Imports c.ElectionPeriod##c.US10YrYields_AnnAvg ElectionYear l.deltaReserves_Imports l.GDPgrowth l.CurrAcctBal_PerGDP l.ExtDebtStocks_PerGNI l.DebtService_PerGDP l.Inflation_annGDPdeflator l.PegBandManaged_NoUnion l.Left  precrisis postcrisis  i.country_num, robust
estimates store c3

vif


estout c1 c2 c3, cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) starlevels(* 0.1 ** 0.05 ) ///
stats(r2 N , fmt(%9.2f %9.0f) labels("R2" ))  style(tex) ///
legend label collabels(none) ///
varlabels(_cons Constant  "c.ElectionPeriod#c.US10YrYields_AnnAvg" "Election*USrates" "c.year#c.GlobalReserveLevels" "Year*GlobalReserves" ) ///
order(ElectionPeriod US10YrYields_AnnAvg ElectionYear   c.ElectionPeriod#c.US10YrYields_AnnAvg  ) drop(*country_num *year) ///
mlabels ("Model 1"  "Model 2") ///
title("") 





***************************************************************************************************************************************************************************
*Section G: Alternative DVs

regress deltaReservesPerGDP_incGold ElectionPeriod ElectionYear  US10YrYields_AnnAvg l.deltaReservesPerGDP_incGold l.GDPpcap l.GDPgrowth l.ny_gdp_totl_rt_zs l.CurrAcctBal_PerGDP l.ExtDebtStocks_PerGNI l.DebtService_PerGDP l.Inflation_annGDPdeflator l.PegBandManaged_NoUnion l.lvaw_garriga l.Taxes_PerGDP l.BestCRtg l.cyrs l.dyrs l.v2x_polyarchy l.Left i.country_num c.year##c.GlobalReserveLevels, robust
estimates store a1

regress deltaReservesPerGDP_incGold c.ElectionPeriod##c.US10YrYields_AnnAvg ElectionYear l.deltaReservesPerGDP_incGold  l.GDPpcap l.GDPgrowth l.ny_gdp_totl_rt_zs l.CurrAcctBal_PerGDP l.ExtDebtStocks_PerGNI l.DebtService_PerGDP l.Inflation_annGDPdeflator l.PegBandManaged_NoUnion l.lvaw_garriga l.Taxes_PerGDP l.BestCRtg l.cyrs l.dyrs l.v2x_polyarchy l.Left i.country_num c.year##c.GlobalReserveLevels, robust
estimates store a2

estout a1 a2, cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) starlevels(+ 0.1 * 0.05 ) ///
stats(r2 N , fmt(%9.2f %9.0f) labels("R2" ))  style(tex) ///
legend label collabels(none) ///
varlabels(_cons Constant  "c.ElectionPeriod#c.US10YrYields_AnnAvg" "Election*USrates" "c.year#c.GlobalReserveLevels" "Year*GlobalReserves" ) ///
order(ElectionPeriod US10YrYields_AnnAvg post_Election   c.ElectionPeriod#c.US10YrYields_AnnAvg  ) keep(ElectionPeriod US10YrYields_AnnAvg post_Election   c.ElectionPeriod#c.US10YrYields_AnnAvg  ) ///
mlabels ("Model 1"  "Model 2") ///
title("") 


gen reserves = deltaReservesPerGDP_incGold*ReservesPerGDP_incGold
gen pdreserves = d.reserves /l.reserves 


regress pdreserves ElectionPeriod ElectionYear  US10YrYields_AnnAvg l.reserves l.GDPpcap l.GDPgrowth l.ny_gdp_totl_rt_zs l.CurrAcctBal_PerGDP l.ExtDebtStocks_PerGNI l.DebtService_PerGDP l.Inflation_annGDPdeflator l.PegBandManaged_NoUnion l.lvaw_garriga l.Taxes_PerGDP l.BestCRtg l.cyrs l.dyrs l.v2x_polyarchy l.Left i.country_num c.year##c.GlobalReserveLevels, robust
estimates store a3

regress pdreserves c.ElectionPeriod##c.US10YrYields_AnnAvg ElectionYear l.reserves  l.GDPpcap l.GDPgrowth l.ny_gdp_totl_rt_zs l.CurrAcctBal_PerGDP l.ExtDebtStocks_PerGNI l.DebtService_PerGDP l.Inflation_annGDPdeflator l.PegBandManaged_NoUnion l.lvaw_garriga l.Taxes_PerGDP l.BestCRtg l.cyrs l.dyrs l.v2x_polyarchy l.Left i.country_num c.year##c.GlobalReserveLevels, robust
estimates store a4

estout a1 a2 a3 a4, cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) starlevels(* 0.1 ** 0.05 ) ///
stats(r2 N , fmt(%9.2f %9.0f) labels("R2" ))  style(tex) ///
legend label collabels(none) ///
varlabels(_cons Constant  "c.ElectionPeriod#c.US10YrYields_AnnAvg" "Election*USrates" "c.year#c.GlobalReserveLevels" "Year*GlobalReserves" ) ///
order(ElectionPeriod US10YrYields_AnnAvg post_Election   c.ElectionPeriod#c.US10YrYields_AnnAvg  ) keep(ElectionPeriod US10YrYields_AnnAvg ElectionYear   c.ElectionPeriod#c.US10YrYields_AnnAvg  ) ///
mlabels ("Model 1"  "Model 2") ///
title("") 


***************************************************************************************************************************************************************************
*Section H: Expanded Sample (Including Mexico and Turkey)

*Re-set so can add Mexico and Turkey from OECD countries
use "data1_final.dta", clear
tsset country_num year

*Subset to developing
keep if oecd_1yes == 0 | iso=="MEX" | iso =="TUR"
*Subset to VDem democracy level
keep if v2x_polyarchy > .42

* Generate pre-election share
replace  monthDPI= . if ElectionPeriod==0 

gen preelec_share = 0 if year <=2020
replace preelec_share = monthDPI/12 if monthDPI != . 
by iso, sort: replace preelec_share = (12-monthDPI[_n+1])/12 if monthDPI[_n+1] != .

tsset country_num year


* Generate post-election share (monthly) 
gen postelec_share = 0 if year <=2020
replace postelec_share = (12-monthDPI)/12 if monthDPI != .

* Generate post-election share (annual) 

gen post_Election =0 if year <=2020
replace post_Election =1 if year <=2020 & ElectionLastYear==1


regress deltaReserves_Imports c.ElectionPeriod US10YrYields_AnnAvg ElectionYear l.deltaReserves_Imports l.GDPpcap l.GDPgrowth l.ny_gdp_totl_rt_zs l.CurrAcctBal_PerGDP l.ExtDebtStocks_PerGNI l.DebtService_PerGDP l.Inflation_annGDPdeflator l.PegBandManaged_NoUnion l.lvaw_garriga l.Taxes_PerGDP l.BestCRtg l.cyrs l.dyrs l.v2x_polyarchy l.Left i.country_num c.year##c.GlobalReserveLevels , robust
estimates store c1

regress deltaReserves_Imports c.ElectionPeriod##c.US10YrYields_AnnAvg ElectionYear l.deltaReserves_Imports l.GDPpcap l.GDPgrowth l.ny_gdp_totl_rt_zs l.CurrAcctBal_PerGDP l.ExtDebtStocks_PerGNI l.DebtService_PerGDP l.Inflation_annGDPdeflator l.PegBandManaged_NoUnion l.lvaw_garriga l.Taxes_PerGDP l.BestCRtg l.cyrs l.dyrs l.v2x_polyarchy l.Left i.country_num c.year##c.GlobalReserveLevels , robust
estimates store c2


estout c1 c2, cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) starlevels(* 0.1 ** 0.05 ) ///
stats(r2 N , fmt(%9.2f %9.0f) labels("R2" ))  style(tex) ///
legend label collabels(none) ///
varlabels(_cons Constant  "c.ElectionPeriod#c.US10YrYields_AnnAvg" "Election*USrates" "c.year#c.GlobalReserveLevels000" "Year*GlobalReserves") ///
keep(ElectionPeriod US10YrYields_AnnAvg c.ElectionPeriod#c.US10YrYields_AnnAvg ElectionYear)  ///
mlabels () ///
title("") 



 ***************************************************************************************************************************************************************************
*Section I: Election Month Robustness

*Re-drop Mexico and Turkey
keep if oecd_1yes == 0

gen ElectionPeriod3 = ElectionPeriod
replace ElectionPeriod3 = 0 if monthDPI<=3

gen ElectionPeriod6 = ElectionPeriod
replace ElectionPeriod6 = 0 if monthDPI<=6

regress deltaReserves_Imports c.ElectionPeriod3 c.US10YrYields_AnnAvg ElectionYear l.deltaReserves_Imports l.GDPpcap l.GDPgrowth l.ny_gdp_totl_rt_zs l.CurrAcctBal_PerGDP l.ExtDebtStocks_PerGNI l.DebtService_PerGDP l.Inflation_annGDPdeflator l.PegBandManaged_NoUnion l.lvaw_garriga l.Taxes_PerGDP l.BestCRtg l.cyrs l.dyrs l.v2x_polyarchy l.Left i.country_num c.year##c.GlobalReserveLevels, robust
estimates store e1a

regress deltaReserves_Imports c.ElectionPeriod3##c.US10YrYields_AnnAvg ElectionYear l.deltaReserves_Imports l.GDPpcap l.GDPgrowth l.ny_gdp_totl_rt_zs l.CurrAcctBal_PerGDP l.ExtDebtStocks_PerGNI l.DebtService_PerGDP l.Inflation_annGDPdeflator l.PegBandManaged_NoUnion l.lvaw_garriga l.Taxes_PerGDP l.BestCRtg l.cyrs l.dyrs l.v2x_polyarchy l.Left i.country_num c.year##c.GlobalReserveLevels, robust
estimates store e1


regress deltaReserves_Imports c.ElectionPeriod6 c.US10YrYields_AnnAvg ElectionYear l.deltaReserves_Imports l.GDPpcap l.GDPgrowth l.ny_gdp_totl_rt_zs l.CurrAcctBal_PerGDP l.ExtDebtStocks_PerGNI l.DebtService_PerGDP l.Inflation_annGDPdeflator l.PegBandManaged_NoUnion l.lvaw_garriga l.Taxes_PerGDP l.BestCRtg l.cyrs l.dyrs l.v2x_polyarchy l.Left i.country_num c.year##c.GlobalReserveLevels, robust
estimates store e2a

regress deltaReserves_Imports c.ElectionPeriod6##c.US10YrYields_AnnAvg ElectionYear l.deltaReserves_Imports l.GDPpcap l.GDPgrowth l.ny_gdp_totl_rt_zs l.CurrAcctBal_PerGDP l.ExtDebtStocks_PerGNI l.DebtService_PerGDP l.Inflation_annGDPdeflator l.PegBandManaged_NoUnion l.lvaw_garriga l.Taxes_PerGDP l.BestCRtg l.cyrs l.dyrs l.v2x_polyarchy l.Left i.country_num c.year##c.GlobalReserveLevels, robust
estimates store e2



estout e1a e1 e2a e2, cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) starlevels(* 0.1 ** 0.05 ) ///
stats(r2 N , fmt(%9.2f %9.0f) labels("R2" ))  style(tex) ///
legend label collabels(none) ///
varlabels(_cons Constant  "c.ElectionPeriod3#c.US10YrYields_AnnAvg" "Election3*USrates" "c.ElectionPeriod6#c.US10YrYields_AnnAvg" "Election6*USrates" ) ///
order(ElectionPeriod3 US10YrYields_AnnAvg ElectionYear  c.ElectionPeriod3#c.US10YrYields_AnnAvg ElectionPeriod6 US10YrYields_AnnAvg post_Election   c.ElectionPeriod6#c.US10YrYields_AnnAvg ) keep(ElectionPeriod3  ElectionPeriod6 US10YrYields_AnnAvg ElectionYear   c.ElectionPeriod3#c.US10YrYields_AnnAvg   c.ElectionPeriod6#c.US10YrYields_AnnAvg  ) ///
mlabels ("Model 1"  "Model 2") ///
title("") 


***************************************************************************************************************************************************************************
*Section J: Debt Effects


regress d.log_gt1yrOnly deltaReserves_Imports i.country_num c.year##c.GlobalReserveLevels, robust
estimates store md1
regress d.log_gt1yrOnly deltaReserves_Imports l.d.log_gt1yrOnly l.Reserves_MonthsOfImports l.US10YrYields_AnnAvg i.country_num c.year##c.GlobalReserveLevels, robust
estimates store md2
regress d.log_gt1yrOnly deltaReserves_Imports l.d.log_gt1yrOnly l.Reserves_MonthsOfImports l.US10YrYields_AnnAvg l.GDPpcap l.GDPgrowth l.ny_gdp_totl_rt_zs l.CurrAcctBal_PerGDP l.ExtDebtStocks_PerGNI l.DebtService_PerGDP l.Inflation_annGDPdeflator l.PegBandManaged_NoUnion l.lvaw_garriga l.Taxes_PerGDP l.BestCRtg l.cyrs l.dyrs l.v2x_polyarchy l.Left i.country_num c.year##c.GlobalReserveLevels, robust
estimates store md3


estout md1 md2 md3, cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) starlevels(* 0.1 ** 0.05 ) ///
stats(r2 N , fmt(%9.2f %9.0f) labels("R2" ))  style(tex) ///
legend label collabels(none) ///
varlabels(_cons Constant "LD.log_gt1yrOnly" "LaggedDV")  ///
order(deltaReserves_Imports LD.log_gt1yrOnly L.Reserves_MonthsOfImports L.US10YrYields_AnnAvg   ) ///
keep(deltaReserves_Imports L.Reserves_MonthsOfImports L.US10YrYields_AnnAvg LD.log_gt1yrOnly) ///
mlabels ("Model 1"  "Model 2") ///
title("")

***************************************************************************************************************************************************************************
*Section K: Additional Interflex binned graphs for monthly 

*Re-create preelec_share2
gen preelec_share2 = preelec_share 
replace preelec_share2 = 1 if F.ElectionPeriod==1 & ElectionPeriod==1 & year <=2020	

*prep variables for interflex
*country and year dummies
tab country_num , g(cc_)
tab year, g(yr_)
*LDV
gen ldeltaReserves_Imports = L.deltaReserves_Imports
*Manual year trends
gen yearGR = year*GlobalReserveLevels

global trends yearGR year GlobalReserveLevels

*Controls
global cntall GDPpcap GDPgrowth ny_gdp_totl_rt_zs CurrAcctBal_PerGDP ExtDebtStocks_PerGNI DebtService_PerGDP Inflation_annGDPdeflator PegBandManaged_NoUnion lvaw_garriga Taxes_PerGDP BestCRtg cyrs dyrs v2x_polyarchy Left

foreach var in GDPpcap GDPgrowth ny_gdp_totl_rt_zs CurrAcctBal_PerGDP ExtDebtStocks_PerGNI DebtService_PerGDP Inflation_annGDPdeflator PegBandManaged_NoUnion lvaw_garriga Taxes_PerGDP BestCRtg cyrs dyrs v2x_polyarchy Left {
	gen lagx_`var' = l.`var'
	}
	
	
	


  *Figure K1 : Election Share (model 6) Bin

 
  interflex deltaReserves_Imports  preelec_share US10YrYields_AnnAvg ldeltaReserves_Imports $trends postelec_share lagx_* cc_*, vce(robust) nbins(4)  ylabel("Reserves") dlabel("Election Share")  xlabel("US Rates")	

 

 
  *Figure K2 : Election  Share (model 8) Bin

  interflex deltaReserves_Imports  preelec_share2 US10YrYields_AnnAvg ldeltaReserves_Imports $trends postelec_share lagx_* cc_*, vce(robust) nbins(4)  ylabel("Reserves") dlabel("Election Share")  xlabel("US Rates")	

 
